﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace FirstHomeWork.Utility
{
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public class EmailAttribute : AbstractValidateAttribute
    {
        public EmailAttribute()
        {

        }


        public override bool Validate(object ovalue)
        {
            if (ovalue == null)            
                return false;            
            string emailRegex = @"[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}";
            return Regex.IsMatch(ovalue.ToString(), emailRegex, RegexOptions.IgnoreCase);
         
        }
    }
}
